class News < ActiveRecord::Base
  paginates_per 10

  has_one :document, :as => :source, :dependent => :destroy

  default_scope order('created_at DESC')
  scope :important, where(:important => true)

  after_initialize lambda { |n| n.build_document }, :unless => :document

  accepts_nested_attributes_for :document

  validates_presence_of :document
end
